import moment from '@/common/moment'
import zhCn from '@/common/locale'
import Vue from 'vue'
moment.defineLocale('zh-cn', zhCn)

export const date = function(val, format = 'YYYY.MM.DD') {
  if (!val) {
    return val
  }
  return moment(val).format(format)
}

// 整数分变为不带单位的元
Vue.filter('fen2yuan', (val) => {
  if (!val) return '0.00'
  return (Number(val) / 100).toFixed(2)
})
export function isValid(val) {
  return val && val !== 'null' && val !== 'undefined'
}
